from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get('https://www.baidu.com')

# xpath层级定位
ipt = driver.find_element(By.XPATH, '//form/span/input')
print(ipt.get_attribute('outerHTML'))

ipt = driver.find_element(By.XPATH, '//form/span')
print(ipt.get_attribute('outerHTML'))

# 退出浏览器
driver.quit()